package com.wc.AlgoOJ_train.train1.c6.A601;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2024/1/10 20:35
 * @description 字符串统计
 * http://43.138.190.70:8888/p/A601
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n-- > 0) {
            String s = sc.next();
            int ans = 0;
            for (char ch : s.toCharArray()){
                if (ch >= '0' && ch <= '9'){
                    ans++;
                }
            }
            System.out.println(ans);
        }
    }
}
